<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>记事本</title>
    <link rel="stylesheet" href="./common.css">
    <link rel="stylesheet" href="./index.css">
    <style>

    </style>
</head>
<body>
    <section id="issue">
        <header class="header">
            <h1>记事本</h1>
            <input type="text" autofocus="autofocus" placeholder="请输入任务" @keyup.enter="add" v-model="inputValue">
        </header>
        <section class="main">
            <section class="todo">
                
                <ul class="do-list">
                    <li class="do" v-for="(item,index) in list">
                        <span>{{ index+1 }}.</span>
                        <label>{{item}}</label>
                        <button class="delete" @click="remove(index)"></button>
                    </li>
                </ul> 
            </section>
            <footer class="footer"  v-show="list.length!=0">
                <span v-text="list.length +' items left'"></span>
                <button class="clearAll"  @click="clearAll">clear</button>
            </footer>
        </section>
    </section>

    <!-- 开发版本环境 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el:"#issue",
            data:{
                list:["吃饭","睡觉","打豆豆"],
                inputValue:"听喜欢的歌",
                
            },
            methods:{
                add:function(){
                    this.list.push(this.inputValue);
                },
                remove:function(index){
                    this.list.splice(index,1)
                },
                clearAll:function(){
                    this.list=[]
                }
            }
        })
    </script>
</body>
</html>